
    tailwind.config = {
      theme: {
        extend: {
          colors: {
            heytea: {
              green: '#00B42A',
              lightGreen: '#E8F7EA',
              darkGreen: '#008000',
              orange: '#FF7D00',
              gray: '#F2F3F5',
              darkGray: '#86909C'
            }
          },
          fontFamily: {
            sans: ['Inter', 'system-ui', 'sans-serif'],
          },
        },
      }
    }



    // 购物车数据

    let cart = [];
    
    // DOM元素
    const navbar = document.getElementById('navbar');
    const mobileMenuBtn = document.getElementById('mobileMenuBtn');
    const mobileMenu = document.getElementById('mobileMenu');
    const cartBtn = document.getElementById('cartBtn');
    const closeCartBtn = document.getElementById('closeCartBtn');
    const cartSidebar = document.getElementById('cartSidebar');
    const overlay = document.getElementById('overlay');
    const cartItems = document.getElementById('cartItems');
    const emptyCart = document.getElementById('emptyCart');
    const cartCount = document.getElementById('cartCount');
    const cartSubtotal = document.getElementById('cartSubtotal');
    const cartPackaging = document.getElementById('cartPackaging');
    const cartTotal = document.getElementById('cartTotal');
    const checkoutBtn = document.getElementById('checkoutBtn');
    const addToCartButtons = document.querySelectorAll('.add-to-cart');
    const addToCartToast = document.getElementById('addToCartToast');
    const categoryItems = document.querySelectorAll('.category-item');
    const productCards = document.querySelectorAll('.product-card');
    
    // 监听滚动事件，改变导航栏样式
    window.addEventListener('scroll', () => {
      if (window.scrollY > 10) {
        navbar.classList.add('shadow');
      } else {
        navbar.classList.remove('shadow');
      }
    });
    
    // 移动端菜单切换
    mobileMenuBtn.addEventListener('click', () => {
      mobileMenu.classList.toggle('hidden');
    });
    
    // 购物车侧边栏控制
    function openCart() {
      cartSidebar.classList.remove('translate-x-full');
      overlay.classList.remove('hidden');
      document.body.style.overflow = 'hidden';
    }
    
    function closeCart() {
      cartSidebar.classList.add('translate-x-full');
      overlay.classList.add('hidden');
      document.body.style.overflow = '';
    }
    
    cartBtn.addEventListener('click', openCart);
    closeCartBtn.addEventListener('click', closeCart);
    overlay.addEventListener('click', closeCart);
    
    // 分类筛选
    categoryItems.forEach(item => {
      item.addEventListener('click', () => {
        // 移除所有分类的active类
        categoryItems.forEach(i => i.classList.remove('active'));
        // 给当前点击的分类添加active类
        item.classList.add('active');
        
        const category = item.getAttribute('data-category');
        
        // 筛选商品
        productCards.forEach(card => {
          if (category === 'all' || card.getAttribute('data-category') === category) {
            card.style.display = 'block';
            // 添加动画效果
            setTimeout(() => {
              card.style.opacity = '1';
              card.style.transform = 'scale(1)';
            }, 50);
          } else {
            card.style.opacity = '0';
            card.style.transform = 'scale(0.95)';
            setTimeout(() => {
              card.style.display = 'none';
            }, 300);
          }
        });
      });
    });
    
    // 初始化默认选中"全部饮品"
    document.querySelector('.category-item[data-category="all"]').classList.add('active');
    
    // 添加到购物车功能
    addToCartButtons.forEach(button => {
      button.addEventListener('click', () => {
        const id = button.getAttribute('data-id');
        const name = button.getAttribute('data-name');
        const price = parseFloat(button.getAttribute('data-price'));
        const img = button.getAttribute('data-img');
        
        // 检查商品是否已在购物车中
        const existingItem = cart.find(item => item.id === id);
        
        if (existingItem) {
          // 如果已存在，增加数量
          existingItem.quantity++;
        } else {
          // 如果不存在，添加到购物车
          cart.push({
            id,
            name,
            price,
            img,
            quantity: 1
          });
        }
        
        // 更新购物车UI
        updateCartUI();
        
        // 显示添加成功提示
        showAddToCartToast();
      });
    });
    
    // 显示添加到购物车提示
    function showAddToCartToast() {
      addToCartToast.style.opacity = '1';
      addToCartToast.style.pointerEvents = 'auto';
      
      setTimeout(() => {
        addToCartToast.style.opacity = '0';
        addToCartToast.style.pointerEvents = 'none';
      }, 2000);
    }
    
    // 更新购物车UI
    function updateCartUI() {
      // 清空购物车列表
      cartItems.innerHTML = '';
      
      // 更新购物车数量
      const totalItems = cart.reduce((total, item) => total + item.quantity, 0);
      cartCount.textContent = totalItems;
      
      // 如果购物车为空，显示空状态
      if (cart.length === 0) {
        cartItems.appendChild(emptyCart);
        checkoutBtn.disabled = true;
      } else {
        // 否则，添加购物车商品
        cart.forEach(item => {
          const cartItemElement = document.createElement('div');
          cartItemElement.className = 'flex items-center justify-between p-2 border-b border-gray-100';
          cartItemElement.innerHTML = `
            <div class="flex items-center">
              <img src="${item.img}" alt="${item.name}" class="w-16 h-16 object-cover rounded-md mr-3">
              <div>
                <h4 class="font-medium">${item.name}</h4>
                <p class="text-heytea-green text-sm">¥${item.price.toFixed(2)}</p>
              </div>
            </div>
            <div class="flex items-center">
              <button class="decrease-qty w-6 h-6 rounded-full border border-gray-300 flex items-center justify-center text-gray-600 hover:bg-gray-100 transition-colors" data-id="${item.id}">
                <i class="fa fa-minus text-xs"></i>
              </button>
              <span class="mx-3 text-gray-700">${item.quantity}</span>
              <button class="increase-qty w-6 h-6 rounded-full border border-gray-300 flex items-center justify-center text-gray-600 hover:bg-gray-100 transition-colors" data-id="${item.id}">
                <i class="fa fa-plus text-xs"></i>
              </button>
            </div>
          `;
          cartItems.appendChild(cartItemElement);
        });
        
        // 添加数量调整事件监听
        document.querySelectorAll('.decrease-qty').forEach(button => {
          button.addEventListener('click', () => {
            const id = button.getAttribute('data-id');
            const item = cart.find(item => item.id === id);
            
            if (item.quantity > 1) {
              item.quantity--;
            } else {
              // 如果数量为1，再减少就从购物车移除
              cart = cart.filter(item => item.id !== id);
            }
            
            updateCartUI();
          });
        });
        
        document.querySelectorAll('.increase-qty').forEach(button => {
          button.addEventListener('click', () => {
            const id = button.getAttribute('data-id');
            const item = cart.find(item => item.id === id);
            item.quantity++;
            updateCartUI();
          });
        });
        
        checkoutBtn.disabled = false;
      }
      
      // 更新价格信息
      const subtotal = cart.reduce((total, item) => total + (item.price * item.quantity), 0);
      const packaging = cart.length > 0 ? 2 : 0; // 假设打包费为2元
      const total = subtotal + packaging;
      
      cartSubtotal.textContent = `¥${subtotal.toFixed(2)}`;
      cartPackaging.textContent = `¥${packaging.toFixed(2)}`;
      cartTotal.textContent = `¥${total.toFixed(2)}`;
    }
    
    // 结算按钮点击事件
    checkoutBtn.addEventListener('click', () => {
      alert('前往结算页面...');
      closeCart();
    });
    
    // 初始化购物车UI
    updateCartUI();

